<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ko">
<head>
	<title>관리자관리 - 중앙선거관리위원회 사이버선거역사관</title>
	<script type="text/javascript">
	// 페이지 이동
	function setPage(page)
	{
		var frm = document.forms["listMap"];
		frm.action = "/bbs/${ bbsMap.BBS_ID }_list.do";
		frm.page.value = page;
		frm.submit();
	}
	
	function downloadFileBtn(file_id, file_job_id)
	{
		location.href='/common/download.do?fileid=' + file_id + '&jobid=' + file_job_id;
	}
	
	function deleteFileBtn(id)
	{
		if(!checkAuth()) return false;
		if (confirm("정말로 삭제하시겠습니까?"))
	  	{	
			var frm = document.forms["deleteFrm"];
			frm.article_id.value = id;
			frm.submit();
			
			return true;
		}    		
	}
	</script>
</head>

<body>
		<form id="listMap" name="listMap" method="get">
		<input type="hidden" name="page" value="1" />
		<input type="hidden" name="conditions" value="${commandMap.conditions}" />
		<input type="hidden" name="words" value="${commandMap.words}" />
		</form>
		<!-- 본문 영역 -->
		<div id="contents">
			<!-- 제목 및 Location 영역 -->
			<div id="location">
				<h3 id="contentTitle"></h3>
				<div id="locationPath"></div>
			</div>
			<script type="text/javascript">
			// 현재 메뉴 경로를 설정한다.
			var pagePath = licationPth.split("_");
			var pathStr = "홈";
			for( var i=0; i < pagePath.length; i++ )
			{
				if (i+1 >= pagePath.length)
					pathStr += " &gt; <strong>" + pagePath[i] + "</strong>";
				else
					pathStr += " &gt; " + pagePath[i]
			}
			document.getElementById("contentTitle").innerHTML = pagePath[ pagePath.length - 1 ];
			document.getElementById("locationPath").innerHTML = pathStr;
			</script>
			<!-- 본문 내용 -->
			<div id="content">
				<div class="boxType01">
					<form name="searchFrm" method="get" action="../bbs/${ bbsMap.BBS_ID }_list.do" >
					<div class="cont ar">
						<select title="검색 조건 선택" name="conditions">
							<option value="article_title">제목</option>
						</select>
						<input type="text" name="words" size="25" />
						<span class="button btnProc04"><input type="submit" value="검색" onclick="searchFnc();"/></span>
					</div>
					</form>
					<form name="deleteFrm" method="post" action="../bbs/${ bbsMap.BBS_ID }_proc.do">
					<input type="hidden" name="mode" value="delete" />
					<input type="hidden" name="bbs_id" value="${bbsMap.BBS_ID}" />
					<input type="hidden" name="article_id" />
					<input type="hidden" name="article_editor" id="article_editor" value="${ adminInfo.admin_name }" />
					<input type="hidden" name="article_editor_id" id="article_editor_id" value="${ adminInfo.admin_id }" />
					</form>
				</div>
				<table cellpadding="0" cellspacing="0" border="0" class="tbl_type01 mt20">
					<colgroup>
						<col width="80px" />
						<col width="180px"/>
						<col width="100px" />
						<col width="100px" />
						<c:if test="${ bbsMap.BBS_FILE_YN eq 'Y' }" >
						<col width="80px" />
						</c:if>
						<col width="100px" />
					</colgroup>
					<thead>
						<tr>
							<th>번호</th>
							<th>제목</th>
							<th>등록자</th>
							<th>등록일</th>
							<c:if test="${ bbsMap.BBS_FILE_YN eq 'Y' }" >
							<th>첨부</th>
							</c:if>
							<th>수정/삭제</th>
						</tr>
					</thead>
					<tbody>
					<c:set var="startno" value="${commandMap.startNo}" />
					<c:forEach items="${listMap2}" var="listMap" varStatus="status">
						<tr>
							<td>${startno}</td>
							<td class="al">
								<a href="${ bbsMap.BBS_ID }_view.do?article_id=${listMap.ARTICLE_ID}">
						<c:choose>
							<c:when test="${fn:length(listMap.ARTICLE_TITLE) > 17}">
								<c:out value="${fn:substring(listMap.ARTICLE_TITLE,0,17)}" />...
							</c:when>
							<c:otherwise>
								${listMap.ARTICLE_TITLE}
							</c:otherwise>
						</c:choose>
								</a>
							</td>
							<td>
								<a href="${ bbsMap.BBS_ID }_view.do?article_id=${listMap.ARTICLE_ID}">${listMap.ARTICLE_WRITER}</a>
							</td>
							<td>
								<a href="${ bbsMap.BBS_ID }_view.do?article_id=${listMap.ARTICLE_ID}">${listMap.ARTICLE_ETC3}</a>
							</td>
							<c:if test="${ bbsMap.BBS_FILE_YN eq 'Y' }" >
								<c:choose>
									<c:when test="${listMap.FILE_YN eq 0 }">
									<td></td>
									</c:when>
									<c:otherwise>
									<c:forEach items="${fileListMap}" var="fileListMap" varStatus="status">
										<c:if test="${fileListMap.FILE_RELATE_ID eq listMap.FILE_RELATE_ID}">
											<td><span class="button btnProc01"><a onclick="downloadFileBtn('${fileListMap.FILE_ID}', '${fileListMap.FILE_JOB_ID}')">다운로드</a></span></td>
										</c:if>	
									</c:forEach>
									</c:otherwise>
								</c:choose>
							</c:if>
							<td>
								<span class="button btnProc01"><a href="${ bbsMap.BBS_ID }_edit.do?article_id=${listMap.ARTICLE_ID}">수정</a></span>
								<span class="button btnProc01"><a onclick="deleteFileBtn('${listMap.ARTICLE_ID}')">삭제</a></span>
							</td>
						</tr>
						<c:set var="startno" value="${startno - 1}" />
					</c:forEach>
					</tbody>
				</table>
				<div class="ar mt15"><span class="button btnProc01"><a onclick="checkAuth('../bbs/${ bbsMap.BBS_ID }_write.do');">글쓰기</a></span></div>
				<%@include file="/include/pageList.jsp"%>
			</div>
		</div>
</body>
</html>